package com.firexxx.study.lock.monitor;

import com.firexxx.study.lock.monitor.markword.MarkWordParser;
import org.openjdk.jol.info.ClassData;
import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;
import org.openjdk.jol.vm.VirtualMachine;

import java.util.List;

/**
 * @description: TODO
 * @author: zhuangzhang2
 * @date: 2020-12-18 16:21
 */
public class JavaHeadParser {

    public static JavaObjectHead parse(Object instance) {
        JavaObjectHead javaObjectHead = new JavaObjectHead();

        VirtualMachine vm = VM.current();
        long word = vm.getLong(instance, 0);
        javaObjectHead.setMarkWord(MarkWordParser.parse(word));

        return javaObjectHead;
    }

}
